import { request } from '@/utils/request';

/**创建订单 */
export const createOrder = (data) => {
  return request({
    url: '/app/order/order/create',
    method: 'post',
    data,
  });
};

/**订单列表 订单状态：0-待付款；1-待发货/未领取；2-已发货；3-已收货/已领取；4-已取消*/
export const listOrder = (query) => {
  return request({
    url: '/app/order/order/page',
    method: 'get',
    query
  });
};

/**取消订单 */
export const cancelOrder = (orderId) => {
  return request({
    url: '/app/order/order/cancel/' + orderId,
    method: 'put',
  });
};

/**订单详情 */
export const orderDetail = (id) => {
  return request({
    url: '/app/order/order/' + id,
    method: 'get',
  });
};

/**
 * 创建预支付订单
 * @param {*} openId
 * @param {*} orderId
 * @returns
 */
export const createPrePayOrder = (openId, orderId) => {
  return request({
    url: '/app/order/order/createPrePayOrder?openId=' + openId + '&orderId=' + orderId,
    method: 'post',
  });
};


export const receiptOrder = (orderId) => {
  return request({
    url: '/app/order/order/receipt/' + orderId,
    method: 'put',
  });
}